package com.yckj.day03;

import java.util.Scanner;

/**
 * TODO 任务1 若有3个班级各有4个学员参赛，从控制台输入各班各学员的成绩，计算各个班级的学员平均分，统计成绩大于85的学员人数有多少?
 *
 * @author shengyuee
 * @version 1.0
 * 2025/7/18 15:05
 */
public class ScoreTask {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double sum = 0.0;
        int count = 0;
        double avgScore = 0.0;
        a: for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 4; j++) {
                System.out.print("请输入第"+(i+1)+"个班级第"+(j+1)+"个学员成绩：");
                if(scan.hasNextDouble()){
                    double score = scan.nextDouble();
                    sum += score;
                    if(score <= 85){
                        continue;
                    }
                    count++;

                }else{
                    i--; // 当输入错误值时，循环完后i多加了1，要减去1
                    System.out.println("请输入成绩分数值");
                    scan.nextLine(); // 清空回车和换行
                    continue a;
                }

            }
            avgScore = sum/4;
            System.out.println("第"+(i+1)+"班级学员的平均成绩是:");
            System.out.printf("%.1f",avgScore);
        }
        System.out.println("大于85分的人数有："+count+"个");

    }
}
